Migrate user_defined tests to insta#15255
Conversation
|
cc @blaginin |
|
Thanks @shruti2522 ! |
|
Hey! I’m a bit worried that now to understand the test you’ll need to look into two places: open the test file and also search for the snapshot file… that’s why in the example pr (#15165) I used inline snapshots. do you think we should use the same approach here? |
Hey @blaginin, you are right about this, at first I tried implementing the inline snapshots only, but I ran into errors while running tests for |
Can you please explain more on this? I tried modifying async
Just to give a bit of context, we had a discussion about inline / file snapshots here: #13672 (comment) and #13672 (comment). To me personally, it feels like we can use snapshot files, but the snapshot itself should give enough information to understand the context. For example, in CLI, you can see program input and tests, and the snapshot file itself doesn't contain a lot of logic. Here I'm not sure if that's the case for ALL the test fixtures? Maybe some of them can be inline? |
alamb
left a comment
There was a problem hiding this comment.
Thanks @blaginin and @shruti2522
I do think that inline snapshots would be better (and more consistent with the rest of the code). Can you please update the PR as suggested by @blaginin and mark the PR ready for review when done?
Thanks again for this (and all the other recent PRs)
Yes, it worked. I was using insta::allow_duplicates!(|| {
insta::with_settings!({
description => description,
}, {
insta::assert_snapshot!(actual, @r###"
+-------------+---------+
| customer_id | revenue |
+-------------+---------+
| paul | 300 |
| jorge | 200 |
| andy | 150 |
+-------------+---------+
"###);
});
})();On changing it to this it worked insta::allow_duplicates! {
insta::with_settings!({
description => description,
}, {
insta::assert_snapshot!(actual, @r###"
+-------------+---------+
| customer_id | revenue |
+-------------+---------+
| paul | 300 |
| jorge | 200 |
| andy | 150 |
+-------------+---------+
"###);
});
} |
alamb
left a comment
There was a problem hiding this comment.
Thank you @shruti2522 and @blaginin -- thi slooks great to me!
| fn fmt_batches(batches: &[RecordBatch]) -> String { | ||
| use arrow::util::pretty::pretty_format_batches; | ||
| match pretty_format_batches(batches) { | ||
| Ok(formatted) => formatted.to_string(), | ||
| Err(e) => format!("Error formatting record batches: {}", e), | ||
| } | ||
| } |
There was a problem hiding this comment.
can we use batches_to_string for that?
| fn fmt_batches(batches: &[RecordBatch]) -> String { | ||
| use arrow::util::pretty::pretty_format_batches; | ||
| match pretty_format_batches(batches) { | ||
| Ok(formatted) => formatted.to_string(), | ||
| Err(e) => format!("Error formatting record batches: {}", e), | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
i think this can be removed as well
| fn fmt_batches(batches: &[RecordBatch]) -> String { | ||
| use arrow::util::pretty::pretty_format_batches; | ||
| match pretty_format_batches(batches) { | ||
| Ok(formatted) => formatted.to_string(), | ||
| Err(e) => format!("Error formatting record batches: {}", e), | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This is a good call -- I took the liberty of pushing a commit to make the change.
|
Thanks @shruti2522 and @blaginin 🙏 |


Which issue does this PR close?
insta#15247 .Rationale for this change
What changes are included in this PR?
migrate tests in
datafusion/core/tests/user_definedto instaAre these changes tested?
Are there any user-facing changes?